package com.zhixiang.xaec.action.system;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.zhixiang.core.command.QueryFilter;
import com.zhixiang.core.web.action.BaseAction;
import com.zhixiang.xaec.entity.system.Position;
import com.zhixiang.xaec.service.system.PositionService;


@Controller
@Scope("prototype")
public class PositionAction extends BaseAction
{

    private static final long serialVersionUID = 8178944878908661181L;

    private Position position;

    @Autowired
    private PositionService positionService;

    public Position getPosition()
    {
        return position;
    }

    public void setPosition(Position position)
    {
        this.position = position;
    }

    public String list()
    {
        QueryFilter localQueryFilter = new QueryFilter(getRequest());
        List<Position>localList = this.positionService.getAll(localQueryFilter);         
        setSuccess(true);
        setTotalCounts(localQueryFilter.getPagingBean().getTotalItems());
        //返回结果集
        setResult(localList);
        return SUCCESS;
    }

    public String get()
    {
        String id = getRequest().getParameter("id");
        if(!"".equals(id)&&id!=null){
        setResult(positionService.get(Long.valueOf(id)));
        }
        return SUCCESS;
    }

    public String delete()
    {
        String[] ids = getRequest().getParameterValues("ids");
        positionService.delete(ids);    
        return SUCCESS;
    }

    public String save()
    {
        positionService.save(position);
        return SUCCESS;
    }

}
